

class Solution {
public:
    int maxDepth(TreeNode* root) {
        if(root ==nullptr) return 0;
        int leftmax=maxDepth(root->left);
        int rightmax=maxDepth(root->right);
        return max(leftmax,rightmax)+1;
    }
};